Deposit Transaction Lifecycle
1. Generate OAuth Access Token
The script builds a JWT client assertion with kid, signs it with PRI_KEY, and exchanges it for an access token.
const jwt = await new SignJWT()
.setProtectedHeader({ alg: 'ES256', kid: PRI_KEY.kid })
.setIssuer(clientId)
.setSubject(clientId)
.setAudience(oktaUrl)
.setExpirationTime('5m')
.setJti(crypto.randomUUID())
.sign(jwkPriKey);
Use the returned access_token as Authorization: Bearer <token> in GraphQL requests.
2. Prepare Wallet + Signing Key
Before deposit calls, the flow:
- lists institution entities,
- selects a network (
network('STR')), - generates an Ed25519 key pair (
generateEd25519Keys()), - creates a wallet via
walletCreatewith the public key.
The Ed25519 private key is used later to sign the approval intent payload.
3. Create Deposit
Call depositCreate with walletId, productId, amount, wire reference, and user ID.
mutation depositCreate($walletId: ID!, $productId: ID!, $value: BigDecimal!, $fedWireRef: String!, $userId: String!) {
depositCreate(institutionInput: {
walletId: $walletId,
productId: $productId,
value: $value,
paymentMethodWire: { fedWireRefNumber: $fedWireRef },
buildSigningPackage: false,
userId: $userId
}) {
depositId
approvalsRequired
}
}
Save depositId from the response.
4. Approve Deposit
Call depositApprove with buildSigningPackage: true to receive the signing payload.
mutation depositApprove($depositId: ID!, $userId: String!) {
depositApprove(institutionApproval: {
depositId: $depositId,
buildSigningPackage: true,
userId: $userId
}) {
intentSigningPackage { payloadType payload }
}
}
5. Sign Intent + Submit
Sign intentSigningPackage.payload using the Ed25519 private key:
const intentSig = intentSignPayload(pubPriKey.priKey, payload);
Then finalize via depositSubmit:
mutation depositSubmit($depositId: ID!, $intentSig: String!) {
depositSubmit(institutionSubmit: { depositId: $depositId, intentSignature: $intentSig }) {
blockchainStatus
}
}
A successful submit returns a valid blockchainStatus and confirms the flow is complete.
Run Example
cd pub/examples
npm install
npm run deposit-flow